package com.es.hr.baoxiao;

import java.util.ArrayList;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import com.es.common.CommonBiz;
import com.es.hr.baoxiaoShenpi.BaoxiaoShenpiBean;
import com.es.hr.baoxiaoShenpi.BaoxiaoShenpiBiz;
import com.es.main.LoginUserBeen;
import com.opensymphony.webwork.interceptor.ServletRequestAware;
import com.opensymphony.xwork.ActionSupport;

public class DetailCTMBaoxiaoAction  extends ActionSupport
implements ServletRequestAware{
	
	HttpServletRequest request;
	
	public void setServletRequest(HttpServletRequest arg0) {
		// TODO Auto-generated method stub
		this.request = arg0;
	}
	
	public String execute() throws Exception{
		String result = "";
		String message = "";
	
		String baoxiao_shenpi_id = this.request.getParameter("baoxiao_shenpi_id");
		String baoxiao_state_string = this.request.getParameter("baoxiao_state_string");
		int baoxiao_state_int = new Integer(baoxiao_state_string).intValue();
		baoxiao_state_string = new CommonBiz().getCommonByTypeAndCode("baoxiaostate", baoxiao_state_string).getCommonValue();
		
		BaoxiaoShenpiBean baoxiaoShenpiBean = new BaoxiaoShenpiBiz().searchBaoxiaoShenpiById(baoxiao_shenpi_id);
		String ctm_code = baoxiaoShenpiBean.getCtm_code();
		String baoxiao_create_index = new Integer(baoxiaoShenpiBean.getBaoxiao_create_index()).toString();
		String baoxiao_create_time = baoxiaoShenpiBean.baoxiao_create_time;
		
		BaoxiaoBiz baoxiaoBiz = new BaoxiaoBiz();
		ArrayList<BaoxiaoBean> beans = baoxiaoBiz.getBaoxiaoDetail(ctm_code, baoxiao_create_index, baoxiao_create_time);
	
		for(int i = 0; i < beans.size(); ++i){
			BaoxiaoBean bean = beans.get(i);
			if(bean.fee_smallclass.equals("通讯费")){
				this.request.setAttribute("tongxun_fee", bean.fee);
				this.request.setAttribute("city_value", bean.city_value);
				this.request.setAttribute("ctm_name", bean.ctm_name);
				this.request.setAttribute("rtm_name", bean.rtm_name);
				this.request.setAttribute("baoxiao_date", bean.baoxiao_lastmodify_time);
			}
			if(bean.fee_smallclass.equals("杂费")){
				this.request.setAttribute("za_fee", bean.fee);
				this.request.setAttribute("za_beizhu", bean.fee_beizhu);
			}
			if(bean.fee_smallclass.equals("电脑补助")){
				this.request.setAttribute("computer_fee", bean.fee);
				this.request.setAttribute("computer_beizhu", bean.fee_beizhu);
			}
			if(bean.fee_smallclass.equals("快递费")){
				this.request.setAttribute("kuaidi_fee", bean.fee);
				this.request.setAttribute("kuaidi_beizhu", bean.fee_beizhu);
			}
			if(bean.fee_smallclass.equals("补上月报销")){
				this.request.setAttribute("lastMouth_fee", bean.fee);
				this.request.setAttribute("lastMouth_beizhu", bean.fee_beizhu);
			}
			if(bean.fee_largeclass.equals("附件")){
				this.request.setAttribute("fileName", bean.fee_smallclass);
				this.request.setAttribute("hasAttach", "true");
			}
			if(!bean.fee_largeclass.equals("差旅费"))
			beans.remove(i--);
		}
		this.request.setAttribute("baoxiaoBean", beans);
		this.request.setAttribute("baoxiao_state", baoxiao_state_string);
		this.request.setAttribute("rtm_yijian", baoxiaoShenpiBean.rtm_pifu_yijian);
		this.request.setAttribute("zongbu_yijian", baoxiaoShenpiBean.zongbu_pifu_yijian);
		return "success";
	}
	
}
